package com.shirley.customcontrols;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.shirley.animatedfloatexpandablelistview.AnimatedFloatELV;
import com.shirley.animatedfloatexpandablelistview.entity.GroupData;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by ZLJ on 2017/12/18.
 * 主界面的Tab2对应的fragment
 */

public class AnimatedFloatELVFragment extends Fragment {

    @BindView(R.id.list_view)
    AnimatedFloatELV listView;
    Unbinder unbinder;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_animated_float_elv, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        listView.setData(constructData());
    }

    private List<GroupData> constructData() {
        List<GroupData> data = new ArrayList<>();
        for (int i = 0; i < 15; i++) {
            GroupData temp = new GroupData();
            temp.setName("Group " + i);
            List<GroupData> children = new ArrayList<>();
            for (int j = 0; j < 5; j++) {
                GroupData child = new GroupData();
                child.setName("children " + i + "-" + j);
                children.add(child);
            }
            temp.setChildren(children);
            data.add(temp);
        }
        return data;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
